<?php
//菜单卡管理
namespace app\siteadmin\model;

use think\Model;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class Role_menu extends Model{

    // 模型初始化
    protected static function init()
    {
        parent::init();
        //TODO:初始化内容
    }


    //角色权限查询
    public function rmList($where){
        $list = $this::name('role_menu')
            ->field('rm.id,rm.rid,rm.mid,rm.jur,rm.bid,button.b_name as b_name,button.b_iden as b_iden,if(button.enable is null ,1,button.enable) as enable')
            ->alias('rm')
            ->leftjoin('button ','button.id = rm.bid')
            ->where($where)
            ->order('rm.id', 'desc')
            ->select();
        return $list;
    }

    //角色权限修改
    public function rmEdit($id,$update){
        $in = $this::update($update, ['id' => $id]);
        return $in;
    }

    //角色权限完全清除修改
    public function rmEditE($rid,$update){
        $in = $this::update($update, ['rid' => $rid]);
        return $in;
    }

    //角色权限添加
    public  function rmAdd(array $data){
        return self::create($data);
    }
  
}
